{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "res = requests.get('http://esf.sh.fang.com/')\n",
    "#res.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http://esf.sh.fang.com/chushou/3_286170510.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286171263.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286173315.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286174372.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286175304.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286176164.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286177267.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286183338.htm\n",
      "==============================\n",
      "http://esf.sh.fang.com/chushou/3_286184061.htm\n",
      "==============================\n"
     ]
    },
    {
     "ename": "IndexError",
     "evalue": "list index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-3-2888d55bf5ef>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0msoup\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mBeautifulSoup\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mres\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'html.parser'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mhouse\u001b[0m \u001b[1;32min\u001b[0m \u001b[0msoup\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mselect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'.houseList dl'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m     \u001b[0murl\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdomain\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mhouse\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mselect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'.title a'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'href'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      6\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0murl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m      7\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"==============================\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mIndexError\u001b[0m: list index out of range"
     ]
    }
   ],
   "source": [
    "from bs4 import BeautifulSoup\n",
    "domain = 'http://esf.sh.fang.com'\n",
    "soup = BeautifulSoup(res.text, 'html.parser')\n",
    "for house in soup.select('.houseList dl'):\n",
    "    url = domain + house.select('.title a')[0]['href']\n",
    "    print(url)\n",
    "    print(\"==============================\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "res = requests.get('http://esf.sh.fang.com/chushou/3_284203774.htm')\n",
    "soup = BeautifulSoup(res.text, 'html.parser')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "info = {}\n",
    "info['標題'] = soup.select('.title h1')[0].text.strip()\n",
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "info['總價'] = soup.select('.zongjia1 .red20b')[0].text\n",
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "for dd in soup.select('dd'):\n",
    "    if '：' in dd.text.strip():\n",
    "        key, value = dd.text.strip().split('：')\n",
    "        info[key] = value"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def getHouseDetail(url):\n",
    "    info = {}\n",
    "    res = requests.get(url)\n",
    "    soup = BeautifulSoup(res.text, 'html.parser')\n",
    "    info['標題'] = soup.select('.title h1')[0].text.strip()\n",
    "    info['總價'] = soup.select('.zongjia1 .red20b')[0].text\n",
    "    for dd in soup.select('dd'):\n",
    "        if '：' in dd.text.strip():\n",
    "            key, value = dd.text.strip().split('：')\n",
    "            info[key] = value\n",
    "    return info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "getHouseDetail('http://esf.sh.fang.com/chushou/3_284203774.htm')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "32\n",
      "33\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "houseary = []\n",
    "#http://esf.sh.fang.com/house/i33/\n",
    "for i in range(32,40):\n",
    "    res = requests.get('http://esf.sh.fang.com/house/i{}/'.format(i))\n",
    "    domain = 'http://esf.sh.fang.com'\n",
    "    soup = BeautifulSoup(res.text, 'html.parser')\n",
    "    print(i)\n",
    "    for house in soup.select('.houseList dl'):\n",
    "        if len(house.select('.title a')) > 0:\n",
    "            url = domain + house.select('.title a')[0]['href']\n",
    "            houseary.append(getHouseDetail(url))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'houseary' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-253b3c4e9290>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhouseary\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m: name 'houseary' is not defined"
     ]
    }
   ],
   "source": [
    "len(houseary)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>专业度</th>\n",
       "      <th>二 手 房</th>\n",
       "      <th>产权性质</th>\n",
       "      <th>住宅类别</th>\n",
       "      <th>使用面积</th>\n",
       "      <th>厅 结 构</th>\n",
       "      <th>参考月供</th>\n",
       "      <th>参考首付</th>\n",
       "      <th>同比去年</th>\n",
       "      <th>地上层数</th>\n",
       "      <th>...</th>\n",
       "      <th>租 房</th>\n",
       "      <th>總價</th>\n",
       "      <th>结构</th>\n",
       "      <th>绿 化 率</th>\n",
       "      <th>花园面积</th>\n",
       "      <th>装修</th>\n",
       "      <th>装修程度</th>\n",
       "      <th>车位数量</th>\n",
       "      <th>车库数量</th>\n",
       "      <th>进门朝向</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.0</td>\n",
       "      <td>111套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>266万</td>\n",
       "      <td>↑1.43%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>97套</td>\n",
       "      <td>760</td>\n",
       "      <td>平层</td>\n",
       "      <td>45.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>豪华装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5.0</td>\n",
       "      <td>84套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>85�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>26.6万</td>\n",
       "      <td>↓11.37%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0套</td>\n",
       "      <td>76</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5.0</td>\n",
       "      <td>1300套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>89�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>28万</td>\n",
       "      <td>暂无资料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0套</td>\n",
       "      <td>80</td>\n",
       "      <td>平层</td>\n",
       "      <td>55.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5.0</td>\n",
       "      <td>1300套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>90�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>28万</td>\n",
       "      <td>暂无资料</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0套</td>\n",
       "      <td>80</td>\n",
       "      <td>平层</td>\n",
       "      <td>55.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>136套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>99.75万</td>\n",
       "      <td>↓8.33%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>38套</td>\n",
       "      <td>285</td>\n",
       "      <td>平层</td>\n",
       "      <td>30.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>中装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>72套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>103.25万</td>\n",
       "      <td>↑38.08%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>29套</td>\n",
       "      <td>295</td>\n",
       "      <td>平层</td>\n",
       "      <td>30.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5</td>\n",
       "      <td>106套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>84万</td>\n",
       "      <td>↑25.99%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>21套</td>\n",
       "      <td>240</td>\n",
       "      <td>平层</td>\n",
       "      <td>36.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>5.0</td>\n",
       "      <td>100套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>72�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>143.5万</td>\n",
       "      <td>↑40.72%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>44套</td>\n",
       "      <td>410</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>5.0</td>\n",
       "      <td>177套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>71�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>140万</td>\n",
       "      <td>↑5.55%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>68套</td>\n",
       "      <td>400</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>5.0</td>\n",
       "      <td>14套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>46�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>94.5万</td>\n",
       "      <td>↑20.06%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>12套</td>\n",
       "      <td>270</td>\n",
       "      <td>平层</td>\n",
       "      <td>34.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>5.0</td>\n",
       "      <td>100套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>47�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>105万</td>\n",
       "      <td>↑40.72%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>44套</td>\n",
       "      <td>300</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>豪华装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>5.0</td>\n",
       "      <td>14套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>43�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>99.75万</td>\n",
       "      <td>↑20.06%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>12套</td>\n",
       "      <td>285</td>\n",
       "      <td>平层</td>\n",
       "      <td>34.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>5.0</td>\n",
       "      <td>39套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>54�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>119万</td>\n",
       "      <td>↑67.96%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>5套</td>\n",
       "      <td>340</td>\n",
       "      <td>平层</td>\n",
       "      <td>42.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>5.0</td>\n",
       "      <td>32套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>60�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>124.25万</td>\n",
       "      <td>↑59.72%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>12套</td>\n",
       "      <td>355</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>5.0</td>\n",
       "      <td>1套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>114�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>297.5万</td>\n",
       "      <td>↑22.15%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>1套</td>\n",
       "      <td>850</td>\n",
       "      <td>平层</td>\n",
       "      <td>40.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>5.0</td>\n",
       "      <td>96套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>66�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>125.65万</td>\n",
       "      <td>↑42.38%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>32套</td>\n",
       "      <td>359</td>\n",
       "      <td>平层</td>\n",
       "      <td>30.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>5.0</td>\n",
       "      <td>100套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>66�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>126万</td>\n",
       "      <td>↑40.72%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>44套</td>\n",
       "      <td>360</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>5.0</td>\n",
       "      <td>31套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>88�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>213.5万</td>\n",
       "      <td>↑27.01%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0套</td>\n",
       "      <td>610</td>\n",
       "      <td>平层</td>\n",
       "      <td>45.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>5.0</td>\n",
       "      <td>39套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>120�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>269.5万</td>\n",
       "      <td>↑67.96%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>5套</td>\n",
       "      <td>770</td>\n",
       "      <td>平层</td>\n",
       "      <td>42.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>5.0</td>\n",
       "      <td>100套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>32�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>77万</td>\n",
       "      <td>↑40.72%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>44套</td>\n",
       "      <td>220</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>简装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1</td>\n",
       "      <td>259套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>69�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>82.6万</td>\n",
       "      <td>↑78.71%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>13套</td>\n",
       "      <td>236</td>\n",
       "      <td>平层</td>\n",
       "      <td>36.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>5.0</td>\n",
       "      <td>515套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>104.3万</td>\n",
       "      <td>↑30.45%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>330套</td>\n",
       "      <td>298</td>\n",
       "      <td>平层</td>\n",
       "      <td>46.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>豪华装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>5.0</td>\n",
       "      <td>344套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>113.75万</td>\n",
       "      <td>↑18.09%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>143套</td>\n",
       "      <td>325</td>\n",
       "      <td>平层</td>\n",
       "      <td>50.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>5.0</td>\n",
       "      <td>214套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>160.3万</td>\n",
       "      <td>↑46.72%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>157套</td>\n",
       "      <td>458</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>5.0</td>\n",
       "      <td>61套</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>挑高</td>\n",
       "      <td></td>\n",
       "      <td>437.5万</td>\n",
       "      <td>↑16.84%</td>\n",
       "      <td>3层</td>\n",
       "      <td>...</td>\n",
       "      <td>9套</td>\n",
       "      <td>1250</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45.00%</td>\n",
       "      <td>400平米</td>\n",
       "      <td>NaN</td>\n",
       "      <td>豪华装修</td>\n",
       "      <td>2个</td>\n",
       "      <td>2个</td>\n",
       "      <td>南</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>5.0</td>\n",
       "      <td>179套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>196万</td>\n",
       "      <td>↑35.56%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>52套</td>\n",
       "      <td>560</td>\n",
       "      <td>平层</td>\n",
       "      <td>47.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>5.0</td>\n",
       "      <td>105套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>227.5万</td>\n",
       "      <td>↑27.87%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>120套</td>\n",
       "      <td>650</td>\n",
       "      <td>平层</td>\n",
       "      <td>50.07%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>5.0</td>\n",
       "      <td>79套</td>\n",
       "      <td>商品房</td>\n",
       "      <td>NaN</td>\n",
       "      <td>35�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>70万</td>\n",
       "      <td>↑1.77%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>43套</td>\n",
       "      <td>200</td>\n",
       "      <td>平层</td>\n",
       "      <td>32.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>5.0</td>\n",
       "      <td>134套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>63�O</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>89.25万</td>\n",
       "      <td>↓1.06%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>36套</td>\n",
       "      <td>255</td>\n",
       "      <td>平层</td>\n",
       "      <td>34.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>5.0</td>\n",
       "      <td>279套</td>\n",
       "      <td>个人产权</td>\n",
       "      <td>普通住宅</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td></td>\n",
       "      <td>157.5万</td>\n",
       "      <td>↑20%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>82套</td>\n",
       "      <td>450</td>\n",
       "      <td>平层</td>\n",
       "      <td>35.00%</td>\n",
       "      <td>NaN</td>\n",
       "      <td>精装修</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>30 rows × 38 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    专业度  二 手 房  产权性质  住宅类别   使用面积 厅 结 构 参考月供     参考首付     同比去年 地上层数 ...   \\\n",
       "0   5.0   111套   商品房  普通住宅    NaN   NaN          266万   ↑1.43%  NaN ...    \n",
       "1   5.0    84套   商品房   NaN   85�O   NaN         26.6万  ↓11.37%  NaN ...    \n",
       "2   5.0  1300套   商品房  普通住宅   89�O   NaN           28万     暂无资料  NaN ...    \n",
       "3   5.0  1300套   商品房  普通住宅   90�O   NaN           28万     暂无资料  NaN ...    \n",
       "4     5   136套  个人产权  普通住宅    NaN   NaN        99.75万   ↓8.33%  NaN ...    \n",
       "5     5    72套  个人产权  普通住宅    NaN   NaN       103.25万  ↑38.08%  NaN ...    \n",
       "6     5   106套  个人产权  普通住宅    NaN   NaN           84万  ↑25.99%  NaN ...    \n",
       "7   5.0   100套   商品房   NaN   72�O   NaN        143.5万  ↑40.72%  NaN ...    \n",
       "8   5.0   177套   商品房  普通住宅   71�O   NaN          140万   ↑5.55%  NaN ...    \n",
       "9   5.0    14套   商品房   NaN   46�O   NaN         94.5万  ↑20.06%  NaN ...    \n",
       "10  5.0   100套   商品房   NaN   47�O   NaN          105万  ↑40.72%  NaN ...    \n",
       "11  5.0    14套   商品房   NaN   43�O   NaN        99.75万  ↑20.06%  NaN ...    \n",
       "12  5.0    39套   商品房   NaN   54�O   NaN          119万  ↑67.96%  NaN ...    \n",
       "13  5.0    32套   商品房   NaN   60�O   NaN       124.25万  ↑59.72%  NaN ...    \n",
       "14  5.0     1套   商品房   NaN  114�O   NaN        297.5万  ↑22.15%  NaN ...    \n",
       "15  5.0    96套   商品房   NaN   66�O   NaN       125.65万  ↑42.38%  NaN ...    \n",
       "16  5.0   100套   商品房   NaN   66�O   NaN          126万  ↑40.72%  NaN ...    \n",
       "17  5.0    31套   商品房   NaN   88�O   NaN        213.5万  ↑27.01%  NaN ...    \n",
       "18  5.0    39套   商品房   NaN  120�O   NaN        269.5万  ↑67.96%  NaN ...    \n",
       "19  5.0   100套   商品房   NaN   32�O   NaN           77万  ↑40.72%  NaN ...    \n",
       "20    1   259套  个人产权  普通住宅   69�O   NaN         82.6万  ↑78.71%  NaN ...    \n",
       "21  5.0   515套  个人产权  普通住宅    NaN   NaN        104.3万  ↑30.45%  NaN ...    \n",
       "22  5.0   344套  个人产权  普通住宅    NaN   NaN       113.75万  ↑18.09%  NaN ...    \n",
       "23  5.0   214套  个人产权  普通住宅    NaN   NaN        160.3万  ↑46.72%  NaN ...    \n",
       "24  5.0    61套   NaN   NaN    NaN    挑高        437.5万  ↑16.84%   3层 ...    \n",
       "25  5.0   179套  个人产权  普通住宅    NaN   NaN          196万  ↑35.56%  NaN ...    \n",
       "26  5.0   105套  个人产权  普通住宅    NaN   NaN        227.5万  ↑27.87%  NaN ...    \n",
       "27  5.0    79套   商品房   NaN   35�O   NaN           70万   ↑1.77%  NaN ...    \n",
       "28  5.0   134套  个人产权  普通住宅   63�O   NaN        89.25万   ↓1.06%  NaN ...    \n",
       "29  5.0   279套  个人产权  普通住宅    NaN   NaN        157.5万     ↑20%  NaN ...    \n",
       "\n",
       "     租 房    總價   结构   绿 化 率   花园面积    装修  装修程度 车位数量 车库数量 进门朝向  \n",
       "0    97套   760   平层  45.00%    NaN  豪华装修   NaN  NaN  NaN  NaN  \n",
       "1     0套    76   平层  35.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "2     0套    80   平层  55.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "3     0套    80   平层  55.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "4    38套   285   平层  30.00%    NaN   中装修   NaN  NaN  NaN  NaN  \n",
       "5    29套   295   平层  30.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "6    21套   240   平层  36.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "7    44套   410   平层  35.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "8    68套   400   平层  35.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "9    12套   270   平层  34.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "10   44套   300   平层  35.00%    NaN  豪华装修   NaN  NaN  NaN  NaN  \n",
       "11   12套   285   平层  34.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "12    5套   340   平层  42.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "13   12套   355   平层  35.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "14    1套   850   平层  40.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "15   32套   359   平层  30.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "16   44套   360   平层  35.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "17    0套   610   平层  45.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "18    5套   770   平层  42.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "19   44套   220   平层  35.00%    NaN   简装修   NaN  NaN  NaN  NaN  \n",
       "20   13套   236   平层  36.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "21  330套   298   平层  46.00%    NaN  豪华装修   NaN  NaN  NaN  NaN  \n",
       "22  143套   325   平层  50.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "23  157套   458   平层  35.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "24    9套  1250  NaN  45.00%  400平米   NaN  豪华装修   2个   2个    南  \n",
       "25   52套   560   平层  47.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "26  120套   650   平层  50.07%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "27   43套   200   平层  32.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "28   36套   255   平层  34.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "29   82套   450   平层  35.00%    NaN   精装修   NaN  NaN  NaN  NaN  \n",
       "\n",
       "[30 rows x 38 columns]"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas\n",
    "df = pandas.DataFrame(houseary)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df.to_excel('house.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
